﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;

using ProjectBase.Core;


using $prjsn$.Entity.Services.HowTos;
using $prjsn$.Common;
using $prjsn$.Common.Data.Services.HowTos;
using $prjsn$.Common.Business.Services.HowTos;

namespace $safeprojectname$.Services.HowTos
{
    /// <summary>
    /// All Business checks for 'ComplexEntity' on CRUD operations
    /// are nested and encapsulated in this ComplexEntityFacade
    /// </summary>
    [CLSCompliant(false)]
    public class ComplexEntityFacade : BaseFacade<ComplexEntity, long, ComplexEntityFilter, IComplexEntityDao>, IComplexEntityFacade
    {
        #region IBaseFacade<T> override - FACTORY METHOD
        /// <summary>
        /// Factory Method pattern.
        /// A central and only point for creating new entity of the type ComplexEntity.
        /// </summary>
        /// <returns>new entity 'ComplexEntity' transient</returns>
        public override ComplexEntity CreateNew()
        {
            var complex = SimpleEntityFacade.Find(new SimpleEntityFilter()).FirstOrDefault();
            return new ComplexEntity
            {
                SimpleAsync = complex,
                ByteValue = 255,
                SByteValue = -128,
                ByteValueNullable = null,
                SByteValueNullable = null,

                ShortValue = -1500,
                UShortValue = 1700,
                ShortValueNullable = null,
                UShortValueNullable = null,
                IntValue = -2300,
                UIntValue = 2500,
                IntValueNullable = null,
                UIntValueNullable = null,
                LongValue = -2700,
                ULongValue = 2900,
                LongValueNullable = null,
                ULongValueNullable = null,

                DecimalValue = -3500.20M,
                DecimalValueNullable = null,
                FloatValue = 4500.50f,
                FloatValueNullable = null,
                DoubleValue = 4700.80d,
                DoubleValueNullable = null,

                GuidValue = Guid.NewGuid(),
                GuidValueNullable = null,

                ValidFrom = DateTime.Now.Date,
                ValidTo = null,
            };
        }

        /// <summary>
        /// Needed for the BaseFacade checks on Update() and Delete().
        /// </summary>
        /// <returns></returns>
        public override ComplexEntityFilter CreateNewFilter()
        {
            return new ComplexEntityFilter
            {
                // TODO
            };
        }
        #endregion IBaseFacade<T> override - FACTORY METHOD

        #region IComplexEntityFacade
        // TODO any application dependent operations,
        // declared in IComplexEntityFacade
        // put here (e.g. 'public virtual bool IsOtherEntityInUse(OtherEntity item)')
        #endregion IComplexEntityFacade

        #region properties

        // NOTE: You MUST extend ISimpleEntityFacade declaration this way:
        // ISimpleEntityFacade SimpleEntityFacade { set; }
        public virtual ISimpleEntityFacade SimpleEntityFacade { protected get; set; }

        #endregion properties
    }
}
